/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dto;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;

/**
 *
 * @author lab
 */
public class Exam implements Serializable {

    private int id;
    private String name;
    private int time;
    private Date startTime;
    private Date endTime;
    private dto.Class cls;
    private Date createdDate;
    private User author;
    private Date modifiedDate;
    private boolean state;
    private ArrayList<Question> questionSet;

    public Exam() {
        id = 0;
        time = 0;
        startTime = new Date();
        endTime = new Date();
        cls = new Class();
        createdDate = new Date();
        author = new User();
        modifiedDate = new Date();
        state = false;
        questionSet = new ArrayList<Question>();
    }

    public Exam(int time, Date startTime, Date endTime, Class cls, User author) {
        id = 0;
        this.time = time;
        this.startTime = startTime;
        this.endTime = endTime;
        this.cls = cls;
        this.createdDate = new Date();
        this.author = author;
        this.modifiedDate = new Date();
        this.state = false;
        this.questionSet = new ArrayList<Question>();
    }

    /**
     * @return the id
     */
    public int getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(int id) {
        this.id = id;
    }

    /**
     * @return the time
     */
    public int getTime() {
        return time;
    }

    /**
     * @param time the time to set
     */
    public void setTime(int time) {
        this.time = time;
    }

    /**
     * @return the startTime
     */
    public Date getStartTime() {
        return startTime;
    }

    /**
     * @param startTime the startTime to set
     */
    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    /**
     * @return the endTime
     */
    public Date getEndTime() {
        return endTime;
    }

    /**
     * @param endTime the endTime to set
     */
    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    /**
     * @return the cls
     */
    public dto.Class getCls() {
        return cls;
    }

    /**
     * @param cls the cls to set
     */
    public void setCls(dto.Class cls) {
        this.cls = cls;
    }

    /**
     * @return the createdDate
     */
    public Date getCreatedDate() {
        return createdDate;
    }

    /**
     * @param createdDate the createdDate to set
     */
    public void setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
    }

    /**
     * @return the author
     */
    public User getAuthor() {
        return author;
    }

    /**
     * @param author the author to set
     */
    public void setAuthor(User author) {
        this.author = author;
    }

    /**
     * @return the modifiedDate
     */
    public Date getModifiedDate() {
        return modifiedDate;
    }

    /**
     * @param modifiedDate the modifiedDate to set
     */
    public void setModifiedDate(Date modifiedDate) {
        this.modifiedDate = modifiedDate;
    }

    /**
     * @return the state
     */
    public boolean isState() {
        return state;
    }

    /**
     * @param state the state to set
     */
    public void setState(boolean state) {
        this.state = state;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the questionSet
     */
    public ArrayList<Question> getQuestionSet() {
        return questionSet;
    }

    /**
     * @param questionSet the questionSet to set
     */
    public void setQuestionSet(ArrayList<Question> questionSet) {
        this.questionSet = questionSet;
    }

    public float getTotalMark() {
        float total = 0;
        for (Question q : this.questionSet) {
            total += q.getMark();
        }
        return total;
    }
}
